package com.hivekion.common.entity.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
public class LoginUser implements UserDetails {
      private String userId;
      private Long loginTime;
      private Long expireTime;
      private boolean isEnabled;
      private String userName;
      private String passWord;
      private List<String> permissions;

      @Override
      public Collection<? extends GrantedAuthority> getAuthorities() {
	    return null;
      }

      @JsonIgnore
      @Override
      public String getPassword() {
	    return this.passWord;
      }

      @JsonIgnore
      @Override
      public String getUsername() {
	    return this.userName;
      }

      /**
       * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
       *
       * @return
       */
      @JsonIgnore
      @Override
      public boolean isAccountNonExpired() {
	    return true;
      }

      /**
       * 指定用户是否解锁,锁定的用户无法进行身份验证
       *
       * @return
       */
      @JsonIgnore
      @Override
      public boolean isAccountNonLocked() {
	    return true;
      }

      /**
       * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
       *
       * @return
       */
      @JsonIgnore
      @Override
      public boolean isCredentialsNonExpired() {
	    return true;
      }

      /**
       * 是否可用 ,禁用的用户不能身份验证
       *
       * @return
       */
      @JsonIgnore
      @Override
      public boolean isEnabled() {
	    return this.isEnabled;
      }
}
